package com.sgzn.sgpay.enums;

import com.sgzn.sgpay.util.EnumUtil;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/**
 * Tcp 响应接受枚举
 * @author huangsenguang
 * @version Id: TcpReceiveEnum.java, v 0.1 2018/7/28 23:11 huangsenguang Exp $$
 */
public enum TcpReceiveEnum {

    TcpResetTerminal("02","tcpResetTerminalHandler","2.复位终端应答"),

    TcpIncreaseCredit("03","tcpIncreaseCreditReceiveHandler","3.云上分应答"),

    TcpQueryTerminalRecordBaby("04","tcpQueryTerminalRecordBabyHandler","4.查询终端账目应答（娃娃机）"),

    TcpQueryTerminalParam("05","tcpQueryTerminalParamHandler","5.查询终端参数应答"),

    TcpSetTerminalParamBaby("06","tcpSetTerminalParamBabyHandler","6.设置终端参数应答(娃娃机)"),

    TcpBoardBillSetZero("07","tcpBoardBillSetZeroHandler","7.面板账目清零应答"),

    TcpBackBillSetZero("08","tcpBackBillSetZeroHandler","8.后台账目清零应答"),

    TcpQueryIncrementBaby("09","tcpQueryIncrementBabyHandler","9.查询增量应答（娃娃机）"),

    TcpRecoveryLeaveFactorySetup("0B","tcpRecoveryLeaveFactorySetupHandler","10.恢复出厂设置应答"),

    TcpLocalBillSetZero("0C","tcpLocalBillSetZeroHandler","11.本地账目清零应答"),

    TcpObtainTwoDimensionCode("10","tcpObtainTwoDimensionCodeHandler","12.获取二维码链接(终端发起)"),

    TcpTerminalInitiativeBillIncrementBaby("13","tcpTerminalInitiativeBillIncrementBabyHandler","13.终端主动上传账目增量（娃娃机终端发起）"),

    TcpTerminalInitiativeBillIncrementExchange("14","tcpTerminalInitiativeBillIncrementExchangeHandler","14.终端主动上传账目增量（兑币机终端发起）"),

    TcpSetTerminalParamExchange("15","tcpSetTerminalParamExchangeHandler","15.设置终端参数应答(兑币机)"),

    TcpQueryTerminalBillExchange("16","tcpQueryTerminalBillExchangeHandler","16.查询终端账目应答（兑币机）"),

    TcpQueryIncrementExchange("17","tcpQueryIncrementExchangeHandler","17.查询增量应答（兑币机）"),

    TcpQuerySignal("19","tcpQuerySignalHandler","19.查询信号(终端发起)"),

    TcpClockingQueryTotalBill("1A","tcpClockingQueryTotalBillHandler","20.定时查询总账应答"),

    TcpClearRewardPool("1C","tcpClearRewardPoolHandler","22.清奖池应答"),

    TcpSetLocalBill("1D","tcpSetLocalBillHandler","23.设置本地账目应答"),

    TcpEpicycleBillClear("1E","tcpEpicycleBillClearHandler","24.本轮账目清零应答"),

    TcpRestartSystem("1F","tcpRestartSystemHandler","25.重启系统应答"),

    TcpObtainBill("30","tcpObtainBillHandler","26.获取账目应答（供手机端查询）"),

    TcpDevicePause("31","tcpDevicePauseHandler","27.设备暂停服务应答"),

    TcpDeviceStart("32","tcpDeviceStartHandler","28.设备开启服务应答"),
    ;

    /**
     * CMD
     */
    @Getter
    private String cmd;

    /**
     * 处理器名称
     */
    @Getter
    private String beanName;

    /**
     * cmd名称
     */
    @Getter
    private String cmdName;

    private TcpReceiveEnum(String cmd, String beanName, String cmdName) {
        this.cmd = cmd;
        this.beanName = beanName;
        this.cmdName = cmdName;
    }

    private static final Map<String, TcpReceiveEnum> map = new HashMap<>();

    static{
        for(TcpReceiveEnum single : TcpReceiveEnum.values()){
            map.put(single.cmd, single);
        }
    }

    public static TcpReceiveEnum resolve(String cmd) {
        return EnumUtil.resolveFromCode(cmd, TcpReceiveEnum.class);
    }

    /**
     * 解释翻译
     * @param cmd
     * @return
     */
    public static final TcpReceiveEnum explain(String cmd) {
        return map.get(cmd);
    }
}

